// Copyright (C) joyinter
// All rights reserved.
// 
// Author : Jiang Li
// Date   : 2005-5-12

#ifndef __CHECKBASE_H_COMMON_GUARD__
#define __CHECKBASE_H_COMMON_GUARD__

#pragma once


namespace JoyGuard
{

//##ModelId=44CF17BF00FA
class CheckBase
{
public:
	//##ModelId=44CF17BF011F
    enum ErrorCode
    {
		//##ModelId=44CF17BF0121
        EC_OK,
		//##ModelId=44CF17BF0128
        EC_FAILED,
		//##ModelId=44CF17BF0129
        EC_READ_MEMORY,
		//##ModelId=44CF17BF012A
        EC_CHECK_IMAGE,
		//##ModelId=44CF17BF012B
        EC_CHECK_FILE,
		//##ModelId=44CF17BF012C
        EC_NO_MODULE,
    };
	//##ModelId=44CF17BF012D
    class ECheckStop : public std::exception
    {
    };

	//##ModelId=44CF17BF00FB
    HANDLE  m_checkThread;
	//##ModelId=44CF17BF00FC
    DWORD   m_error;
	//##ModelId=44CF17BF00FD
    HANDLE  m_waitEvent;
	//##ModelId=44CF17BF00FE
    DWORD   m_readSize;
	//##ModelId=44CF17BF00FF
    DWORD   m_readDelay;
	//##ModelId=44CF17BF0100
    DWORD   m_readed;
	//##ModelId=44CF17BF0109
    DWORD   m_checkDelay;
	//##ModelId=44CF17BF010A
    bool    m_stopped;

	//##ModelId=44CF17BF010B
    void CheckStop();
	//##ModelId=44CF17BF010C
    void ReadMemory(HANDLE hProcess, BYTE* dst, BYTE* src, int len);

	//##ModelId=44CF17BF0111
    virtual void CheckProc();
public:

	//##ModelId=44CF17BF0119
    CheckBase();
	//##ModelId=44CF17BF011A
    ~CheckBase();

	//##ModelId=44CF17BF011B
    virtual bool Create();
	//##ModelId=44CF17BF011D
    virtual void Close();
};


} // namespace JoyGuard

#endif  // __CHECKBASE_H_COMMON_GUARD__
